remove all richText

Hello,

what is the trick in removing all richText syntax from a string? It's one of those days!!! Thank you.

-Jim
SystemAdmin - Wed Sep 26 13:06:04 EDT 2012

Re: remove all richText
kbmurphy - Wed Sep 26 13:22:21 EDT 2012

Object o = current
string s =  o."Object Text" ""
o."Object Text" = s

Re: remove all richText
SystemAdmin - Wed Sep 26 13:43:18 EDT 2012

kbmurphy - Wed Sep 26 13:22:21 EDT 2012

Object o = current
string s =  o."Object Text" ""
o."Object Text" = s

Hello,

I'm trying to display text as richText within a DBE but when I parse it I only want the string no richText(this may vary so all richText needs to be removed) any ideas. the code in still in progress I normally clean it up after I have my logic down. Thank you.

-Jim
 

#include <utils/copyops.inc>
 
DB IED
DBE textDBE
DBE statusDBE
DBE revisionDBE
 
Skip RPE = create()
 
put(RPE, 0,"project_reference_1")
put(RPE, 1,"project_reference_2")
put(RPE, 2,"unit")
put(RPE, 3,"sub_activity_1")
put(RPE, 4,"sub_activity_2")
put(RPE, 5,"sub_activity_3")
put(RPE, 6,"sub_activity_4")
put(RPE, 7,"sub_activity_5")
put(RPE, 8,"main_activity_1")
put(RPE, 9,"main_activity_2")
put(RPE, 10,"originator_1")
put(RPE, 11,"originator_2")
put(RPE, 12,"originator_3")
put(RPE, 13,"originator_4")
put(RPE, 14,"serial_number_1")
put(RPE, 15,"serial_number_2")
put(RPE, 16,"serial_number_3")
put(RPE, 17,"type_1")
put(RPE, 18,"type_2")
put(RPE, 19,"_revision")
put(RPE, 20,"_status")
 
const string cMod = fullName current Module
//http://www.ibm.com/developerworks/forums/thread.jspa?threadID=455956&tstart=15
Module EP0304rev2 = load (moduleVersion("00000a70"),false) 
 
Module modTgt = edit (cMod, true, false, true) //switch Source Module to Edit-mode
if (!isEdit modTgt || ! canCreate modTgt) { infoBox("not editable") }
 
void rpeATTR()
{
    string sAttrName = null
        for sAttrName in RPE do
        {
                //infoBox(sAttrName)
                AttrDef adSrc = find(EP0304rev2, sAttrName) 
                if (null adSrc) { errorBox("Null {"sAttrName"}") }
                else
                {
                        AttrDef adTgt = find (modTgt, sAttrName) 
                        if (!null adTgt) { /* inform user that attribute exists, and ask if he wants to overwrite */ 
                        } else {
                           copyAttrDefRename_ (adSrc, EP0304rev2, modTgt, sAttrName)
                        }
                }
        }
        close EP0304rev2
}
 
void valuesATTR()
{
        string sAttrName = null
        string temp = null
        for sAttrName in RPE do
        {
                int cnt = (int key RPE)
                if(cnt == 19)
                { set(revisionDBE, modTgt.sAttrName"")
                } else if(cnt == 20)
                { set(statusDBE, modTgt.sAttrName"")
                }else
                { temp = temp modTgt.sAttrName""
                }
        }
        temp = "{\\b "temp"}"
        set(textDBE,temp)
}
 
bool SyntaxChecker(string txt)
{
        int pos
        bool ret = true
 
        for (pos = 0; pos < length(txt); pos++) { 
        if (isspace(txt[pos])) { ret = false }}
        
        if( length(txt) != 19 ) { ret = false }
        
        return ret
}
 
void checker(DB win)
{
        if(SyntaxChecker(get(textDBE)))
        {
                string sAttrName = null
                for sAttrName in RPE do
                {
                        int cnt = (int key RPE)
                        if(cnt == 19)
                        {
                                string txt = get(revisionDBE)
                                modTgt.sAttrName = upper(txt)
                        } else if(cnt == 20)
                        {
                                string txt = get(statusDBE)
                                modTgt.sAttrName = upper(txt)
                        }
                        else
                        {
                                string txt = get(textDBE)
                                modTgt.sAttrName = upper(txt[cnt]"")
                        }
                }
                
                modTgt."_status" = get(statusDBE)
                modTgt."_revision" = get(revisionDBE)
        }else { warningBox("Syntax Error") }
}
 
 
IED = create "IDE"
textDBE = richText(IED, "IED", "FQX57100765401A44GN", 150, 30, false)
statusDBE = text(IED, "Status", "CFC", 150, 30, false)
revisionDBE = text(IED, "revision", "A PRE", 150, 30, false)
apply(IED, "Apply",checker)
 
rpeATTR()
valuesATTR()
 
realize IED
setSize(IED,250,230)
show IED

Re: remove all richText
Mathias Mamsch - Wed Sep 26 16:35:27 EDT 2012

SystemAdmin - Wed Sep 26 13:43:18 EDT 2012

Hello,

I'm trying to display text as richText within a DBE but when I parse it I only want the string no richText(this may vary so all richText needs to be removed) any ideas. the code in still in progress I normally clean it up after I have my logic down. Thank you.

-Jim
 

#include <utils/copyops.inc>
 
DB IED
DBE textDBE
DBE statusDBE
DBE revisionDBE
 
Skip RPE = create()
 
put(RPE, 0,"project_reference_1")
put(RPE, 1,"project_reference_2")
put(RPE, 2,"unit")
put(RPE, 3,"sub_activity_1")
put(RPE, 4,"sub_activity_2")
put(RPE, 5,"sub_activity_3")
put(RPE, 6,"sub_activity_4")
put(RPE, 7,"sub_activity_5")
put(RPE, 8,"main_activity_1")
put(RPE, 9,"main_activity_2")
put(RPE, 10,"originator_1")
put(RPE, 11,"originator_2")
put(RPE, 12,"originator_3")
put(RPE, 13,"originator_4")
put(RPE, 14,"serial_number_1")
put(RPE, 15,"serial_number_2")
put(RPE, 16,"serial_number_3")
put(RPE, 17,"type_1")
put(RPE, 18,"type_2")
put(RPE, 19,"_revision")
put(RPE, 20,"_status")
 
const string cMod = fullName current Module
//http://www.ibm.com/developerworks/forums/thread.jspa?threadID=455956&tstart=15
Module EP0304rev2 = load (moduleVersion("00000a70"),false) 
 
Module modTgt = edit (cMod, true, false, true) //switch Source Module to Edit-mode
if (!isEdit modTgt || ! canCreate modTgt) { infoBox("not editable") }
 
void rpeATTR()
{
    string sAttrName = null
        for sAttrName in RPE do
        {
                //infoBox(sAttrName)
                AttrDef adSrc = find(EP0304rev2, sAttrName) 
                if (null adSrc) { errorBox("Null {"sAttrName"}") }
                else
                {
                        AttrDef adTgt = find (modTgt, sAttrName) 
                        if (!null adTgt) { /* inform user that attribute exists, and ask if he wants to overwrite */ 
                        } else {
                           copyAttrDefRename_ (adSrc, EP0304rev2, modTgt, sAttrName)
                        }
                }
        }
        close EP0304rev2
}
 
void valuesATTR()
{
        string sAttrName = null
        string temp = null
        for sAttrName in RPE do
        {
                int cnt = (int key RPE)
                if(cnt == 19)
                { set(revisionDBE, modTgt.sAttrName"")
                } else if(cnt == 20)
                { set(statusDBE, modTgt.sAttrName"")
                }else
                { temp = temp modTgt.sAttrName""
                }
        }
        temp = "{\\b "temp"}"
        set(textDBE,temp)
}
 
bool SyntaxChecker(string txt)
{
        int pos
        bool ret = true
 
        for (pos = 0; pos < length(txt); pos++) { 
        if (isspace(txt[pos])) { ret = false }}
        
        if( length(txt) != 19 ) { ret = false }
        
        return ret
}
 
void checker(DB win)
{
        if(SyntaxChecker(get(textDBE)))
        {
                string sAttrName = null
                for sAttrName in RPE do
                {
                        int cnt = (int key RPE)
                        if(cnt == 19)
                        {
                                string txt = get(revisionDBE)
                                modTgt.sAttrName = upper(txt)
                        } else if(cnt == 20)
                        {
                                string txt = get(statusDBE)
                                modTgt.sAttrName = upper(txt)
                        }
                        else
                        {
                                string txt = get(textDBE)
                                modTgt.sAttrName = upper(txt[cnt]"")
                        }
                }
                
                modTgt."_status" = get(statusDBE)
                modTgt."_revision" = get(revisionDBE)
        }else { warningBox("Syntax Error") }
}
 
 
IED = create "IDE"
textDBE = richText(IED, "IED", "FQX57100765401A44GN", 150, 30, false)
statusDBE = text(IED, "Status", "CFC", 150, 30, false)
revisionDBE = text(IED, "revision", "A PRE", 150, 30, false)
apply(IED, "Apply",checker)
 
rpeATTR()
valuesATTR()
 
realize IED
setSize(IED,250,230)
show IED

I think I saw a plainText function in some other post, which seems to do just that. Maybe it helps, regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: remove all richText
SystemAdmin - Wed Sep 26 22:06:55 EDT 2012

Mathias Mamsch - Wed Sep 26 16:35:27 EDT 2012
I think I saw a plainText function in some other post, which seems to do just that. Maybe it helps, regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

hello,

can anyone tell me why when I run the follow code and do not change any inputs and hit apply it shows "_revision" and "_status" as changed but none of the other attributes. Also when I change all inputs it still only shows "_revision" and "_status" as changed in the module history. Thank you.

-Jim
 

#include <utils/copyops.inc>
 
DB IED
DBE textDBE
DBE statusDBE
DBE revisionDBE
 
Skip RPE = create()
 
put(RPE, 0,"project_reference_1")
put(RPE, 1,"project_reference_2")
put(RPE, 2,"unit")
put(RPE, 3,"sub_activity_1")
put(RPE, 4,"sub_activity_2")
put(RPE, 5,"sub_activity_3")
put(RPE, 6,"sub_activity_4")
put(RPE, 7,"sub_activity_5")
put(RPE, 8,"main_activity_1")
put(RPE, 9,"main_activity_2")
put(RPE, 10,"originator_1")
put(RPE, 11,"originator_2")
put(RPE, 12,"originator_3")
put(RPE, 13,"originator_4")
put(RPE, 14,"serial_number_1")
put(RPE, 15,"serial_number_2")
put(RPE, 16,"serial_number_3")
put(RPE, 17,"type_1")
put(RPE, 18,"type_2")
put(RPE, 19,"_revision")
put(RPE, 20,"_status")
 
const string cMod = fullName current Module
Module EP0304rev2 = load (moduleVersion("00000a70"),false)
 
Module modTgt = edit (cMod, true, false, true) //switch Source Module to Edit-mode
if (!isEdit modTgt || ! canCreate modTgt) { infoBox("not editable") }
 
void closedb (DB win)
{
    delete RPE
        destroy(IED)
        IED = null
}
 
void rpeATTR()
{
        string sAttrName = null
        for sAttrName in RPE do
        {
                //infoBox(sAttrName)
                AttrDef adSrc = find(EP0304rev2, sAttrName) 
                if (null adSrc) { errorBox("Null {"sAttrName"}") }
                else
                {
                        AttrDef adTgt = find (modTgt, sAttrName) 
                        if (!null adTgt) { /* inform user that attribute exists, and ask if he wants to overwrite */ 
                        } else {
                           copyAttrDefRename_ (adSrc, EP0304rev2, modTgt, sAttrName)
                        }
                }
        }
        close EP0304rev2
}
 
void syntaxRichText(string txt)
{
        int pos
        Buffer temp = create
        for (pos = 0; pos < length(txt); pos++) 
        { 
                if (isspace(txt[pos]) || !isalnum(txt[pos])) 
                { temp += "{\\b #}" }
                else
                { temp += txt[pos] }
        }
        
        set(textDBE,stringOf(temp))
        delete temp
}
 
void valuesATTR()
{
        string sAttrName = null
        Buffer temp = create
        for sAttrName in RPE do
        {
                int cnt = (int key RPE)
                if (cnt == 19)
                { set(revisionDBE, modTgt.sAttrName"")
                } else if (cnt == 20)
                { set(statusDBE, modTgt.sAttrName"")
                }else{ 
                        if (null modTgt.sAttrName"")
                        { temp += "{\\b #}" }
                        else { temp += modTgt.sAttrName"" }
                }
        }
        set(textDBE, stringOf(temp))
        syntaxRichText(plainText(get(textDBE)))
        delete temp
}
 
bool SyntaxChecker(string txt)
{
        int pos
        bool ret = true
 
        for (pos = 0; pos < length(txt); pos++) { 
        if (isspace(txt[pos]) || !isalnum(txt[pos])) { ret = false } }
        
        if( length(txt) != 19 ) { ret = false }
        
        if(!ret) { syntaxRichText(plainText(get(textDBE))) }
        
        return ret
}
 
void checker(DB win)
{
        if (SyntaxChecker(plainText(get(textDBE))))
        {
                if (!null plainText(get(statusDBE)))
                {
                        if (!null plainText(get(revisionDBE)))
                        {
                                string sAttrName = null
                                for sAttrName in RPE do
                                {
                                        int cnt = (int key RPE)
                                        if (cnt == 19)
                                        {
                                                string txt = plainText(get(revisionDBE))
                                                modTgt.sAttrName = txt
                                        } else if (cnt == 20)
                                        {
                                                string txt = plainText(get(statusDBE))
                                                modTgt.sAttrName = txt
                                        }
                                        else
                                        {
                                                string txt = plainText(get(textDBE))
                                                modTgt.sAttrName = upper(txt[cnt]"")
                                        }
                                }
                                
                                valuesATTR()
                        } else { warningBox("Null {revision}") }
                } else { warningBox("Null {status}") }
        } else { warningBox("Syntax Error") }
}
 
 
IED = create "IDE"
textDBE = richText(IED, "IED", "sample", 150, 30, false)
statusDBE = richText(IED, "Status", "sample", 150, 30, false)
revisionDBE = richText(IED, "revision", "sample", 150, 30, false)
apply(IED, "Apply",checker)
close (IED, true, closedb) 
 
rpeATTR()
valuesATTR()
 
realize IED
setSize(IED,250,230)
show IED